<ui:composition
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:q="http://huliqing.name/qfaces"
    xmlns:g="http://huliqing.name/qblog"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:c="http://java.sun.com/jsp/jstl/core"
    template="/WEB-INF/template/layout_system.xhtml">

    <ui:define name="subTabName">
        <c:set var="subTabName" value="backup" />
    </ui:define>

    <ui:define name="menuTitle">
        <h:graphicImage url="/_res/image/star.png" height="40" styleClass="alignM" /> 
        数据备份及恢复
        <g:help helpId="BackupConfig" style="width:500px;"/> 
    </ui:define>

    <ui:define name="menuContent">
        <style type="text/css">
            .col1 {width:90px;}
        </style>
        <q:saveState value="#{backupWe.backupEn}" />

        <h:form>
            <h:panelGrid columns="2" border="0" headerClass="header alignL"
                         cellpadding="3"
                         cellspacing="3"
                         rowClasses="row1,row2"
                         columnClasses="col1,,,"
                         width="100%">
                <f:facet name="header">
                    <h:panelGroup>
                        <h:outputText value="备份" />
                    </h:panelGroup>
                </f:facet>

                <h:outputLabel for="properties" value="系统参数" />
                <h:selectBooleanCheckbox id="properties" value="#{backupWe.backupProperties}" />

                <h:outputLabel for="pages" value="页面模块" />
                <h:selectBooleanCheckbox id="pages" value="#{backupWe.backupPages}" />

                <h:outputLabel for="modules" value="应用模块" />
                <h:selectBooleanCheckbox id="modules" value="#{backupWe.backupModules}" />

                <h:outputLabel for="backupName" value="名称" />
                <h:panelGroup>
                    <h:inputText id="backupName" value="#{backupWe.backupEn.name}" size="40" />
                    <q:validator for="backupName" required="true" messageError="请填写一个备份名称，该名称不能与已经存在的相同" displayFlag="false" />
                </h:panelGroup>

                <h:outputLabel for="des" value="备注" />
                <h:inputText id="des" value="#{backupWe.backupEn.des}" style="width:99%;" />

                <h:panelGroup />
                <h:commandButton value="开始备份数据" action="#{backupWe.backup}" />
            </h:panelGrid>
        </h:form>

        <h:form style="margin-top: 20px;">
            <q:scroller for="backupList"
                            listener="#{backupWe.loadData}"
                            var="backup"
                            displayJump="false"
                            sortFields=",,createDate,,">
                    <h:dataTable id="backupList"
                                 binding="#{backupWe.uiBackupEns}"
                                 headerClass="header"
                                 border="0"
                                 width="100%"
                                 styleClass="dotted"
                                 rowClasses="row1,row2"
                                 columnClasses="col1,alignL,alignC,alignC"
                                 cellpadding="3"
                                 cellspacing="3">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="备份列表" />
                            </f:facet>
                            <h:commandLink action="#{backupWe.export}" styleClass="marginLR">
                                <h:graphicImage url="/_res/image/button-export.gif" height="18" title="导出备份文件" />
                            </h:commandLink>
                            <h:commandLink action="#{backupWe.restore}" styleClass="marginLR" onclick="return confirm('您确定要恢复这个备份吗？');" >
                                <h:graphicImage url="/_res/image/button-edit.gif" title="用这个备份进行恢复" />
                            </h:commandLink>
                            <h:commandLink action="#{backupWe.delete}" styleClass="marginLR" onclick="return confirm('#{text['p.toDelete']}');" >
                                <h:graphicImage url="/_res/image/button-delete.gif" title="删除这个备份" />
                            </h:commandLink>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Backup Name" />
                            </f:facet>
                            <h:outputText value="#{backup.name}" />
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Create Date" />
                            </f:facet>
                            <h:outputText value="#{backup.createDate}" >
                                <f:convertDateTime pattern="#{app.dateTimeFormat}" timeZone="#{app.timeZone}" />
                            </h:outputText>
                        </h:column>

                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Description" />
                            </f:facet>
                            <h:outputText value="#{backup.des}" />
                        </h:column>
                    </h:dataTable>
                </q:scroller>
        </h:form>

        <!-- Import --> 
        <h:form id="myform" enctype="multipart/form-data" style="margin-top: 20px;" >
            <h:panelGrid columns="1" headerClass="header" width="100%" 
                         styleClass="alignL"
                         cellpadding="3"
                         cellspacing="3">
                <f:facet name="header">
                    <h:outputText value="从外部文件导入" />
                </f:facet>
                <h:panelGroup>
                    <g:fileUpload id="myFile" binding="#{backupWe.uiFileUpload}" />
                    <h:commandButton value="Import" action="#{backupWe.importBackup}" />
                </h:panelGroup>
            </h:panelGrid>
        </h:form>


    </ui:define>
</ui:composition>